Skip to content

feat: support overriding module-dir#240

Merged
toastwaffle merged 2 commits intoplease-build:masterfrom
VJftw:feat-support-overriding-module-dir
Apr 25, 2025
Merged

feat: support overriding module-dir#240
toastwaffle merged 2 commits intoplease-build:masterfrom
VJftw:feat-support-overriding-module-dir

Conversation

@VJftw
Copy link
Contributor

@VJftw VJftw commented Apr 25, 2025

👋 We'd like to be able to add tools available on PyPi and manage their dependencies separately from the rest of our codebase (e.g. semgrep depends on a few modules that we use in the codebase but are incompatibly versioned).

At the moment, it appears we're constrained by the ModuleDir parameter to this plugin where we can only have one repository-wide directory for Python modules.

This PR makes this configurable per python_binary, python_test and python_wheel which enables us to do things like this:

# third_party/python/pipdeptree/BUILD
# The below command works to run `pipdeptree`.
# $ plz run //third_party/python/pipdeptree:pipdeptree

python_wheel(
    name = "pipdeptree",
    version = "2.26.1",
    module_dir = "third_party.python.pipdeptree",
    hashes = ["3849d62a2ed641256afac3058c4f9b85ac4a47e9d8c991ee17a8f3d230c5cffb"],
    binary = True,
    deps = [":packaging", ":pip"],
    licences = ["MIT"],
)

python_wheel(
    name = "packaging",
    hashes = ["5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"],
    licences = [
        "Apache-2.0",
        "BSD-2-Clause",
    ],
    version = "24.1",
)

python_wheel(
    name = "pip",
    hashes = ["a775837439bf5da2c1a0c2fa43d5744854497c689ddbd9344cf3ea6d00598540"],
    licences = ["MIT"],
    version = "24.1",
)

`python_binary`, `python_test` and `python_wheel` all currently only support
using the repository-wide module-dir which forces us to share the same set of
python dependencies for every binary. This commit allows overriding this so we
can independently version dependencies.
@VJftw VJftw marked this pull request as ready for review April 25, 2025 15:41
@toastwaffle
Copy link
Contributor

Want to bump the plugin version so this gets released?

@toastwaffle toastwaffle merged commit 45b69fc into please-build:master Apr 25, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants